/**
 * Created by Zhang Haijun on 2017/4/27.
 */
app.controller('operateNetworkModalCtrl', ['$scope', '$modalInstance', '$stateParams', 'httpLoad', 'CommonData',  'id', 'itemData',
	function ($scope, $modalInstance, $stateParams, httpLoad, CommonData, id, itemData) {
		$scope.modalTitle = '新增网络设备';
		$scope.typeData = CommonData.networkVmType;
		if(itemData){
			itemData = JSON.parse(JSON.stringify(itemData));
			if(itemData.operation != 'ADD'){
				$scope.hideType = true;
				$scope.modalTitle = '编辑网络设备';
				itemData.operation = 'EDIT';
				$scope.data = itemData;
			}else{
				$scope.data = itemData;
			}
		}else{
			$scope.data = {
				operation:'ADD',
				disLabel:'新增网卡'
			};
		}
		(function () {
			httpLoad.loadData({
				url:'/vm/networks',
				method: 'GET',
				data:{
					id: id
				},
				success:function(data){
					if(data.success){
						$scope.networkListData = data.data;
					}
				}
			});
		})();
		$scope.ok = function () {
			$modalInstance.close($scope.data);
		}
		$scope.cancle = function () {
			$modalInstance.dismiss('cancel');
		};
	}
]);